import request from '@/utils/request'

export default {
  getOrganizationList(searchModel) {
    return request({
      url: '/organization/list',
      method: 'get',
      params: {
        orgDept: searchModel.orgDept,
        pageNo: searchModel.pageNo,
        pageSize: searchModel.pageSize
      }
    })
  },
  addOrganization(organization) {
    return request({
      url: '/organization/add',
      method: 'post',
      data: organization
    })
  },
  saveOrganization(organization) {
    if (organization.orgId == null || organization.orgId === undefined) {
      return this.addOrganization(organization)
    }
    return this.updateOrganization(organization)
  },
  updateOrganization(organization) {
    return request({
      url: '/organization/update',
      method: 'put',
      data: organization
    })
  },
  getOrganizationById(id) {
    return request({
      // url: '/organization/' + id,
      url: `/organization/${id}`,
      method: 'get'
    })
  },
  deleteOrganizationById(id) {
    return request({
      url: `/organization/delete/${id}`,
      method: 'delete'
    })
  },
  getAllOrganizationList() {
    return request({
      url: '/organization/all',
      method: 'get'
    })
  },
}
